package jianzhu.controller;

import jianzhu.entity.BjEntity;
import jianzhu.entity.JianZhuEntity;
import jianzhu.entity.Page;
import jianzhu.entity.PageUtils;
import jianzhu.service.JianZhuService;

import javax.annotation.Resource;
import java.util.List;

public class JianZhuController {
    Page  page=null;
    JianZhuEntity jianZhuEntity=null;
    String name = null;
    Integer pageNo=null;
    List<BjEntity> bjEntity=null;
    String flag="0";
    @Resource
    JianZhuService jianZhuService;

    public String queryPage(){
        //实现分页查询功能
        int totalCount= jianZhuService.queryCount(name);
        page=PageUtils.getPage(5,totalCount,pageNo);
        List<JianZhuEntity> list =jianZhuService.queryPage(page,name);
        page.setData(list);
        return "queryPage";
    }
    public String save(){
        jianZhuService.save(jianZhuEntity);
        flag="1";
        return "save";
    }
    public String del(){
        jianZhuService.del(jianZhuEntity);
        flag = "1";
        return "save";
    }
    public String edit(){
        jianZhuEntity =  jianZhuService.edit(jianZhuEntity);
        return "edit";
    }
    public String bj(){
        bjEntity =jianZhuService.bj();
        return "bj";
    }
    //@Resource @Autowired 作用相同 去spring容器中到bean实例
    //@Service @Component 向spring 容器中放入bean（类的对象）实例




    public JianZhuEntity getJianZhuEntity() {
        return jianZhuEntity;
    }

    public void setJianZhuEntity(JianZhuEntity jianZhuEntity) {
        this.jianZhuEntity = jianZhuEntity;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getFlag() {
        return flag;
    }

    public void setFlag(String flag) {
        this.flag = flag;
    }

    public JianZhuService getJianZhuService() {
        return jianZhuService;
    }

    public void setJianZhuService(JianZhuService jianZhuService) {
        this.jianZhuService = jianZhuService;
    }

    public Integer getPageNo() {
        return pageNo;
    }

    public void setPageNo(Integer pageNo) {
        this.pageNo = pageNo;
    }

    public Page getPage() {
        return page;
    }

    public void setPage(Page page) {
        this.page = page;
    }

    public List<BjEntity> getBjEntity() {
        return bjEntity;
    }

    public void setBjEntity(List<BjEntity> bjEntity) {
        this.bjEntity = bjEntity;
    }
}
